package com.bwie.controller;

import com.bwie.pojo.TbOrder;
import com.bwie.pojo.TbProdInfo;
import com.bwie.service.TbOrderService;
import com.bwie.utils.Result;
import com.bwie.vo.PageInfoVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author 军哥
 * @version 1.0
 * @description: TODO
 * @date 2025/6/2 16:04
 */

@RestController
@RequestMapping( "/shop/order")
public class TbOrderController {

    @Autowired
    TbOrderService tbOrderService;

    /**
     * @description 下订单
     * @params [prodInfoList]
     * @return com.bwie.utils.Result
     * @author 军哥
     * @date 2025/6/2 16:17
     */
    @PostMapping("/addOrder")
    public Result addOrder(@RequestBody List<TbProdInfo> prodInfoList) {
        return tbOrderService.addOrder(prodInfoList);
    }

    /**
     * @description 分页获取订单列表
     * @params [pageInfoVo]
     * @return com.bwie.utils.Result
     * @author 军哥
     * @date 2025/6/2 18:08
     */
    @PostMapping("/getOrderList")
    public Result getOrderList(@RequestBody PageInfoVo pageInfoVo) {
        return tbOrderService.getOrderList(pageInfoVo);
    }

    /**
     * @description 批量删除订单
     * @params [tbOrderList]
     * @return com.bwie.utils.Result
     * @author 军哥
     * @date 2025/6/3 10:05
     */
    @PostMapping( "/deleteAll")
    public Result deleteAll(@RequestBody  List<TbOrder> tbOrderList) {
        return tbOrderService.deleteAll(tbOrderList);
    }

    /**
     * @description 导出订单表格
     * @params [ids]
     * @return void
     * @author 军哥
     * @date 2025/6/3 10:31
     */
    @GetMapping ("/exportExcel/{ids}")
    public void exportExcel(@PathVariable("ids") String ids) {
        tbOrderService.exportExcel(ids);
    }
}
